home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 2 / BBS in a box - Trilogy II.iso / Files / Newton / Util / RPMDemo1 / RPMDemo1 README next >
Encoding:
Text File  |  1993-08-29  |  3.2 KB  |  65 lines  |  [TEXT/EDIT]

  1. README for Newton program "RPMDemo1"       Robert P. Munafo, 1993 August 29
  2.  
  3. RPMDemo1 is a sample Newton program posted in source form as an example for
  4. aspiring Newton programmers.  It demonstrates techniques for the following:
  5.  
  6. - Show two floaters (protoFloatNGo views)
  7. - Each floater allows the user to input text by writing in a protoInputLine
  8.   field inside the floater.
  9. + Each floater can be dragged by starting at any point in the floater that is
  10.   not inside the protoInputLine.
  11. * When dragged, the floater moves to the front and the other objects on the
  12.   screen are redrawn properly.
  13. - When information in either floater is changed, the main view updates its
  14.   display.  Specifically, the text entered in the first floater is repeated N
  15.   times, where N is determined by a number entered in the second floater.
  16. - Input fields use two undocumented font styles (tsCondense and tsShadow).
  17.  
  18. Item "+" was non-trivial.  The typical approach (using a viewClickScript in the
  19. floater's template to do the dragging) doesn't work because it ends up catching
  20. clicks that come from the protoInputLine; this causes the protoInputLine to
  21. drag and to not accept written input.
  22.  
  23. The solution to that was to use the protoStaticText field, a sibling of the
  24. protoInputLine, to catch clicks and pass a Drag message to its parent.
  25.  
  26. The proper redrawing (item "*") was by far the most non-intuitive.  Simply
  27. creating two protoFloatNGo views and allowing them to be dragged doesn't work
  28. -- whichever view is in front gets drawn properly all the time, but the other
  29. floater doesn't get drawn properly if it is partly covered by the first
  30. floater and is then dragged.
  31.  
  32. The solution for this is to bring the floater to the front before dragging. 
  33. This is accomplished by the following:
  34.  
  35.   theFloater:Hide();
  36.   theFloater:Show();
  37.   theFloater:Dirty();
  38.   RefreshViews();
  39.  
  40. The last two lines can be left out if you have defined a viewEffect for your
  41. floater.  To illustrate the difference between a viewEffect and the
  42. Dirty()/RefreshViews() method, the two floaters are done in two different
  43. ways. The text floater ("Say what?") uses viewEffect, and the number
  44. floater ("How many times?") uses Dirty()/RefreshViews().  You will probably
  45. notice that the "Say what?" floater responds faster.
  46.  
  47. Useful things to note:
  48.  
  49. - The word and count are remembered when you close and re-open the application
  50. (but not across reboots) because the application's view frame stays in memory. 
  51. However, all child views are deleted -- so it does not remember the positions
  52. of the floaters.
  53.  
  54. - The function which generates the text by repeating the word N times uses a
  55. log(N) algorithm for speed.  The method used is to start with a single
  56. occurrance of the word, then to repeatedly double and add one if the next bit
  57. in the count is set.  It's kind of analagous to the "Russian peasant"
  58. multiplication method.  (If I had used a simple "for i:=1 to count do" loop it
  59. would have been *much* slower when the count is in the hundreds or thousands.)
  60.  
  61. - I have tried the undocumented "condensed" font style with different sizes,
  62. and it doesn't seem to work.  It works with 14, though, probably because 14
  63. is available as a "bitmap font" in the Newton.  This is probably why the
  64. condensed style is not documented.
  65.